package date20200923.com.kgc.service.impl;

import date20200923.com.kgc.dao.GoodDao;
import date20200923.com.kgc.entity.GoodDetail;
import date20200923.com.kgc.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class GoodServiceImpl implements GoodService{

    @Autowired
    private GoodDao dao;


    @Transactional(readOnly = true)
    @Override
    public List<GoodDetail> listGoods(String sortId,int currentPage) {
        Map<String,Object> map = new HashMap<>();

        if (!"0".equals(sortId)){
            map.put("sortId",sortId);
        }

        map.put("start",currentPage);

        return dao.listGoods(map);

    }

    @Override
    public int count(String sortId) {
        Map<String,Object> map = new HashMap<>();

        if (!"0".equals(sortId)){
            map.put("sortId",sortId);
        }


        return dao.count(map);
    }
}
